<script>
    var ticket_cost = 140;
    $().ready(function(){
        
        $("#qty").change(function(){
            cal_cost();
        });
        cal_cost();
    });
    
    function cal_cost(){
        var subtotal = ticket_cost * parseInt($("#qty").val());
        if(isNaN(subtotal))
            $("#subtotal").html('0');
        else
            $("#subtotal").html(subtotal);
    }
</script>

<div class="book_ticket">
    <h1>BUY/BOOK/TICKET</h1>
    <table class="details">
        <tr>
            <td class="first">Cinema</td>
            <td><?php echo $branch->name;?></td>
        </tr>    
        <tr>
            <td>Movie</td>
            <td><?php echo $movie->title;?></td>
        </tr>
        <tr>
            <td>Date</td>
            <td><?php echo date('D j M Y',strtotime($schedule->start_time));?></td>
        </tr>
        <tr>
            <td>Show time</td>
            <td><?php echo date('H:i',strtotime($schedule->start_time));?></td>
        </tr>
        <tr>
            <td>Screen</td>
            <td><?php echo $cinema->name;?></td>
        </tr>
    </table>    
    <?php echo isset($errors) ? '<span class="form-msg-error">'.$errors.'</span>' : '' ?>
    <?php echo validation_errors();?>
    <form class="form" action="" method="post" accept-charset="utf-8" >
    <table class="book">
        <tr>
            <td>Type of ticket</td>
            <td>QTY</td>
            <td>COST</td>
            <td>SUB TOTAL</td>
        </tr>
        <tr>
            <td>INTERNET TICKET</td>
            <td><input id="qty" type="text" value="" name="qty" /></td>
            <input type="hidden" value="<?php echo $schedule->id;?>" name="schedule_id" />
            <td>140 THB</td>
            <td style="text-align:left;" ><span id="subtotal">0</span> THB</td>
        </tr>
    </table> 
    
    <div class="submit">
        <input type="button" value="CANCEL"/>
        <input type="submit" value="BUY"/>
    </div>   
    </form> 
</div>    